home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
STRINGS
/
PACKAGE6
/
COPY.DOC
< prev
next >
Wrap
Text File
|
1990-07-25
|
3KB
|
65 lines
------------------------------------------------------------------------------
CopyString
------------------------------------------------------------------------------
declaration: procedure CopyString ( OriginalString:
TypeString;
NumberOfChracters,
Position:
integer;
var ResultString:
TypeString);
purpose: Returns a portion of a string (original) in another
string (result).
preconditions: OriginalString was originally initiialized.
NumberOfCharacters has been a given a meaningfull value.
Position has been given a meaningfull value.
ResultString may be undefined.
postconditions: ResultString is filled with the desired number of characters
from the original string from left to right starting from
the position in the original string designated by
Position.
special cases: -where Position > 0
-if NumberOfCharacters + Position >= OriginalString._Length
then ResultString = the characters in
OriginalString._PackedArray starting at Position until the
Counter > OriginalString._Length.
-if NumberOfCharacters <= 0 then ResultString._Length = 0 and
ResultString._PackedArray is not changed.
-if Position <= 0 then ResultString._Length = 0 and
ResultString._PackedArray is not changed.
example: var
OriginalString,
ResultString:
TypeString;
NumberOfCharacters,
Position:
integer;
LastKey:
TypeKey;
begin
.
.
.
ReadlnString (OriginalString, MaxStringLength, LastKey);
NumberOfCharacters:= 2;
Position:= 3;
CopyString (OriginalString, NumberOfCharacters, Position,
ResultString);
write(output,'The third and fourth characters are ==>> ');
WriteString (ResultString);
writeln(output,'.');
.
.
.
end
------------------------------------------------------------------------------